import 'package:flutter/material.dart';
import 'dart:async';
import 'package:intl/intl.dart';

class DateTimePicker extends StatelessWidget {
  DateTimePicker({Key key, this.selectdDate, this.selectDate})
      : super(key: key);

  final DateTime selectdDate;
  final ValueChanged<DateTime> selectDate;

  Future _selectDate(BuildContext context) async {
    DateTime picked = await showDatePicker(
      context: context,
      initialDate: selectdDate,
      firstDate: new DateTime(2015, 8),
      lastDate: new DateTime(2100),
    );
    if (picked != null) {
      selectDate(picked);
    }
  }

  @override
  Widget build(BuildContext context) {
    return new InkWell(
      onTap: () => _selectDate(context),
      child: Row(
        children: <Widget>[
          new Icon(
            Icons.today,
            color: Theme.of(context).primaryColor,
            // size: 25.0,
          ),
          Padding(
            padding: const EdgeInsets.only( left:8.0),
            child: new Text(
              new DateFormat.yMd("en_US").format(selectdDate),
            ),
          ),
        ],
      ),
    );
  }
}
